﻿using System;
using System.Collections.Generic;
using EzDesk.Apps.Model.Attendance;
using System.ServiceModel;
using EzDesk.Utility.ServiceStatusInfo;
namespace EzDesk.Apps.Interface.Attendance
{
    
    public interface IAttendanceService
    {
        
        StatusInfo ApplyLeave(LeaveInfo info);

        
        StatusInfo AuditLeave(Guid leaveInfoId, bool isAgreed, string auditNote, Guid auditId);

        
        StatusInfo<AttendanceStatus> GetDefaultAttendanceStatus(Guid userId, DateTime time);

        
        StatusInfo<AttendanceStatus> GetAttendanceStatus(Guid userId, DateTime actionTime, AttendanceType attendanceInfo);

        
        StatusInfo CheckAttendance(Guid userId, DateTime actionTime, AttendanceType attendanceType, string explaination, bool sendMainPanelFeed = true);

        
        StatusInfo<List<LeaveType>> GetAllLeaveTypes();

        
        StatusInfo<AttendanceConfig> GetAttendanceConfig();

        
        StatusInfo<List<AttendanceInfo>> GetAttendanceInfoListByUsersInDay(DateTime day, List<Guid> userIdList = null, AttendanceType? attendanceType = null);
        
        StatusInfo<List<AttendanceInfo>> GetAttendanceInfoListByUserInDay(DateTime day, Guid userId, AttendanceType? attendanceType = null);
        
        StatusInfo<List<AttendanceInfo>> GetAttendanceInfoListByUsersBetweenDays(DateTime startDate, DateTime endDate, List<Guid> userIdList = null, AttendanceType? attendanceType = null);
        
        StatusInfo<List<AttendanceInfo>> GetAttendanceInfoListByUserBetweenDays(DateTime startDate, DateTime endDate, Guid userId, AttendanceType? attendanceType = null);

        
        StatusInfo<DayAttendanceRemark> UpdateAttendanceRemarkInDay(Guid userId, DateTime day, string remark);
        
        StatusInfo<List<DayAttendanceRemark>> GetAttendanceRemarkListByUserInDay(DateTime day, Guid userId);
        
        StatusInfo<List<DayAttendanceRemark>> GetAttendanceRemarkListByUsersInDay(DateTime day, List<Guid> userIdList);
        
        StatusInfo<List<DayAttendanceRemark>> GetAttendanceRemarkListByUserBetweenDays(
            DateTime startDate,
            DateTime endDate,
            Guid userId);

        
        StatusInfo<DayInfo> GetDayInfo(Guid userId, DateTime theDay);
        
        StatusInfo<List<DayInfo>> GetDayInfos(Guid userId, DateTime startDay, DateTime endDay);

        
        StatusInfo<DayLeaveInfo> GetDayLeaveInfo(Guid userId, DateTime theDay);
        
        StatusInfo<List<DayLeaveInfo>> GetDayLeaveInfos(Guid userId, DateTime startDay, DateTime endDay);

        
        StatusInfo<LeaveInfo> GetLeaveInfoById(Guid leaveId);

        
        StatusInfo<List<LeaveInfo>> GetLeaveInfoList(
            DateTime? startTime, DateTime? endTime,
            DateTime? createTimeStart, DateTime? createTimeEnd,
            Guid? userId, bool? isAudited, bool? isAgreed);

        
        StatusInfo<LeaveType> GetLeaveTypeyById(Guid leaveTypeId);


        /// <summary>
        /// 获得某人某一天的考勤评估信息
        /// </summary>
        /// <param name="memberstring"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        
        StatusInfo<List<DayAttendanceEvaluation>> GetDayAttendanceEvaluation(Guid userId, DateTime date);
        
        StatusInfo<List<DayAttendanceEvaluation>> GetDayAttendanceEvaluations(Guid userId, DateTime startDate, DateTime endDate);


        /// <summary>
        /// 申请修改自己的考勤评估信息
        /// </summary>
        /// <param name="userId">申请人的UserId</param>
        /// <param name="date">申请修改的时间</param>
        /// <param name="applyText">申请理由</param>
        
        StatusInfo ApplyEvaluationModify(Guid userId, DateTime date, string applyText);

        /// <summary>
        /// 获得当前正在进行中的考勤评估修改申请信息
        /// </summary>
        /// <param name="memberstring"></param>
        /// <param name="date"></param>
        /// <returns>如果没有正在进行中的申请，返回null</returns>
        
        StatusInfo<List<EvaluationModifyApplication>> GetCurrentEvaluationModifyApplication(string memberstring, DateTime date);
        
        StatusInfo<List<EvaluationModifyApplication>> GetCurrentEvaluationModifyApplications(string memberstring, DateTime startDate, DateTime endDate);

        /// <summary>
        /// 获得每天最新的修改历史
        /// 如果这天没有修改过，那么就置空，如果这天评估被人修改过，那么返回最后修改的那一条历史
        /// </summary>
        /// <param name="memberstring"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        
        StatusInfo<List<EvaluationModifyHistory>> GetDayLatestEvaluationModifyHistorys(string memberstring, DateTime startDate,
                                                                                      DateTime endDate);
        
        StatusInfo<List<EvaluationModifyHistory>> GetDayLatestEvaluationModifyHistory(string memberstring, DateTime date);

        /// <summary>
        /// 获得某人某一天的所有考勤评估修改申请信息
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        
        StatusInfo<List<EvaluationModifyApplication>> GetEvaluationModifyApplications(Guid userId, DateTime date);


        /// <summary>
        /// 修改某人某一天的考勤评估
        /// </summary>
        /// <param name="newAttendanceEvaluation">对考勤评估记录的修改</param>
        /// <param name="operatorId"></param>
        
        StatusInfo ModifyEvaluation(DayAttendanceEvaluation newAttendanceEvaluation, Guid operatorId);

        /// <summary>
        /// 拒绝某个人的考勤评估申请
        /// </summary>
        /// <param name="actorId"></param>
        /// <param name="applicationId"></param>
        
        StatusInfo RejectEvaluationApplication(Guid actorId, Guid applicationId);

        /// <summary>
        /// 获得某人某一天的考勤评估记录的修改历史
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        
        StatusInfo<List<EvaluationModifyHistory>> GetEvaluationModifyHistory(Guid userId, DateTime date);

        /// <summary>
        /// 判断一天考勤是不是重复
        /// </summary>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        
        StatusInfo<bool> IsDuplicateLeave(DateTime startTime, DateTime endTime, Guid userId);

        /// <summary>
        /// 发送每日考勤报告给HR
        /// </summary>
        
        void SendDailyAttendanceStatics();

        /// <summary>
        /// 发送每日考勤结果给个人
        /// </summary>
        
        void SendDailyAttendanceReport();
    }
}
